-
Notifications
You must be signed in to change notification settings - Fork 594
upgrade yarn scheduler driver memory to ByteAmount #1728
base: master
Are you sure you want to change the base?
Conversation
@@ -87,6 +87,17 @@ public static ByteAmount getByteAmount(Object o) { | |||
} | |||
} | |||
|
|||
public static ByteAmount getByteAmountMB(Object o) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a utility method for each unit, I think adding a unit to the existing method would be better. For e.g. getByteAmount(Object o)
will become getByteAmount(Object o, ByteAmountUnit unit). This is same as the usage pattern of java.util.concurrent.Delayed.getDelay(TimeUnit unit)
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@billonahill - It seems we don't have ByteAmountUnit
class currently. Do you think it is a good idea if we add a new class in c.t.h.common.basics
in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mycFelix actually, now I think @ashvina's suggestion is better. It would be nice to add a enum class ByteAmountUnit
in the same style of SystemConfigKey
to expose MB
and GB
in a typed manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@objmagic - Understood. Thank you for your suggestion.
public static int heronDriverMemoryMb(Config cfg) { | ||
return cfg.getIntegerValue(YarnKey.YARN_SCHEDULER_DRIVER_MEMORY_MB.value(), | ||
YarnKey.YARN_SCHEDULER_DRIVER_MEMORY_MB.getDefaultInt()); | ||
public static ByteAmount heronDriverMemoryMb(Config cfg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove mb
from method name since ByteAmount is generic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
return cfg.getIntegerValue(YarnKey.YARN_SCHEDULER_DRIVER_MEMORY_MB.value(), | ||
YarnKey.YARN_SCHEDULER_DRIVER_MEMORY_MB.getDefaultInt()); | ||
public static ByteAmount heronDriverMemoryMb(Config cfg) { | ||
return cfg.getByteAmountValueMB(YarnKey.YARN_SCHEDULER_DRIVER_MEMORY_MB.value(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, remove MB
from method name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
@objmagic - Thanks for reviewing. I'm agree with you. At first, I think putting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should introduce ByteAmountUnit
. The point of ByteAmount
is that config users will know how to create a ByteAmount (because they know the units), and put it in the config for others to leverage. Those others should not need to know what the unit in the config is, hence the ByteAmount
class exists. It is a representation of bytes that consumers can get in whatever unit they need to, without knowledge of how the units at play when the config value was added. Creating ByteAmountUnit
just allows the ability for the lazy to read a long and convert it to a ByteAmount
if they happen to know the correct unit. This is undesirable and is exactly what we're trying to prevent with the ByteAmount
class. It implies that the config consumer knows the unit that the config producer used when adding the config, which should not be the case (this pattern is super bug-prone). Instead, the agent that puts the size into the config should know the units, and create a ByteAmount
up front.
@@ -161,7 +162,7 @@ Configuration getHMDriverConf() { | |||
.set(HeronDriverConfiguration.HTTP_PORT, 0) | |||
.set(HeronDriverConfiguration.VERBOSE, false) | |||
.set(YarnDriverConfiguration.QUEUE, queue) | |||
.set(DriverConfiguration.DRIVER_MEMORY, driverMemory) | |||
.set(DriverConfiguration.DRIVER_MEMORY, driverMemory.asMegabytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused here. Shouldn't DRIVER_MEMORY
accept value of type int, according to reef?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, it make me confused too. I didn't notice that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@objmagic - cast it to int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can just cast here...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mycFelix I now think I am not the right person to review this PR. You can think about Bill's review and wait for @ashvina's comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@objmagic - Sure~
Considering @billonahill 's comment, creating @ashvina @billonahill - How about we make 2048 into 2048 * 1024 here? |
} | ||
} | ||
|
||
public static ByteAmount getByteAmount(Object o, ByteAmountUnit unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be useful to add javadocs for these overloaded methods.
is there any update on this? seems we have very few things left to do for this PR? @mycFelix @billonahill |
As #1727 mentioned and #1707 refactored, this PR upgraded
driverMemory
to use ByteAmount.The key changes are following:
driverMemory
from int to ByteAmountHeronMasterDriver
cc: @billonahill @ashvina